package com.graduation.community_manager.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.graduation.community_manager.dao.CmHouseDao;
import com.graduation.community_manager.entity.CmEleWaterEntity;
import com.graduation.community_manager.entity.CmHouseEntity;
import com.graduation.community_manager.service.CmHouseService;
import com.graduation.community_manager.vo.PageCmHouseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("cmHouseService")
public class CmHouseServiceImpl extends ServiceImpl<CmHouseDao, CmHouseEntity> implements CmHouseService {

    @Autowired
    private CmHouseDao cmHouseDao;

    @Override
    public IPage<CmHouseEntity> cmHousePage(PageCmHouseVO pageCmHouseVO) {
        QueryWrapper<CmHouseEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", pageCmHouseVO.getUseId());
        wrapper.like("user_name",pageCmHouseVO.getUserName()); // 添加用户名的模糊查询条件
        wrapper.eq("building",pageCmHouseVO.getBuilding());
        wrapper.eq("unit",pageCmHouseVO.getUnit());
        IPage<CmHouseEntity> page = super.page(Page.of(pageCmHouseVO.getCurrent(), pageCmHouseVO.getSize()), wrapper);
        return page;
    }

    @Override
    public List<CmHouseEntity> getCmHouseInfoList(PageCmHouseVO vo) {
        return cmHouseDao.getCmHouseInfoList(vo);
    }
}
